//
//  LSMatchExponentDataCell.m
//  LookScore
//
//  Created by wr on 2018/1/26.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSMatchExponentDataCell.h"
#import "LSExponentModel.h"
@interface LSMatchExponentDataCell()

@property(strong,nonatomic)NSMutableArray *controlArray;

@end

@implementation LSMatchExponentDataCell
-(NSMutableArray *)controlArray{
    if (!_controlArray) {
        _controlArray=[NSMutableArray array];
    }return _controlArray;
}

+(LSMatchExponentDataCell *)MatchExponentDataCellByTableView:(UITableView *)tableView{
    LSMatchExponentDataCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSMatchExponentDataCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
    
    CGFloat width=LSScreenWidth/5;
    for (int i=0; i<4; i++) {
        UILabel *shamLabel = [UILabel new];
//        LSSubGrayColorf7
        shamLabel.backgroundColor=[UIColor whiteColor];
        shamLabel.textColor = LSSubColorB4B4B4;
        shamLabel.font=LSFontSize12;
        shamLabel.numberOfLines=2;
        shamLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:shamLabel];
        shamLabel.sd_layout.leftEqualToView(self.contentView).offset(width*i).topEqualToView(self.contentView).bottomEqualToView(self.contentView).widthIs(width);
        
        [self.controlArray addObject:shamLabel];
    }
    
    
    UIView *lineView=[[UIView alloc]init];
    lineView.backgroundColor=LSLineGrayColor;
    [self.contentView addSubview:lineView];
    self.lineView=lineView; lineView.sd_layout.leftEqualToView(self.contentView).rightEqualToView(self.contentView).bottomEqualToView(self.contentView).heightIs(.5f);
    
}

- (void)setDataType:(NSString *)dataType{
    
    _dataType = dataType;
}

- (void)setModel:(companyData *)model{
    
    _model = model;
    NSArray * array;
    NSString * timeStr = [model.ChangeTime stringByReplacingOccurrencesOfString:@" " withString:@"\n"];
    
    if ([_dataType isEqualToString:@"op"]) {
        array = @[timeStr,model.Odds_Win,model.Odds_Flat,model.Odds_Negative];
    }else if ([_dataType isEqualToString:@"yp"]){
        
        array = @[timeStr,model.HD_ZD,model.HD_PK,model.HD_KD];
    }else{
        
        array = @[timeStr,model.HD_DQ,model.HD_PK,model.HD_XQ];
    }
    
   
    [self.controlArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *shamLabel=(UILabel *)obj;
        
        shamLabel.text = array[idx];
    }];
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation LSMatchExponentCompanyDataCell

+(LSMatchExponentCompanyDataCell *)MatchExponentCompanyDataCellByTableView:(UITableView *)tableView;
{
    LSMatchExponentCompanyDataCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSMatchExponentCompanyDataCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        
        cell.backgroundColor = Color(247, 247, 247);
//        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
  
    UILabel *companyLabel=[UILabel new];
    companyLabel.font=LSFontSize12;
    companyLabel.textAlignment = NSTextAlignmentCenter;
    companyLabel.textColor = LSSubColor5D5D5D;

    [self.contentView addSubview:companyLabel];
    self.companyLabel=companyLabel;
    self.companyLabel.sd_layout
    .leftEqualToView(self.contentView)
    .topEqualToView(self.contentView)
    .rightEqualToView(self.contentView)
    .bottomEqualToView(self.contentView);
    
    UIView *lineView=[[UIView alloc]init];
    lineView.backgroundColor=LSLineGrayColor;
    [self.contentView addSubview:lineView];
    self.lineView=lineView; lineView.sd_layout
    .leftEqualToView(self.contentView)
    .rightEqualToView(self.contentView)
    .bottomEqualToView(self.contentView)
    .heightIs(.5f);

}


- (void)setModel:(OddsChangeRecordList *)model{
    
    _model = model;
    
    self.companyLabel.text = model.CompanyName;
    
}

-(void)setAiModel:(AIHistoricaDataList *)aiModel{
    _aiModel = aiModel;
    self.companyLabel.text = aiModel.CompanyName;
    
}

- (void)setSdModel:(SDHistoricaDataList *)sdModel{
    
    _sdModel = sdModel;
     self.companyLabel.text = sdModel.CompanyName;
}

-(void)companyEvent:(UIButton *)sender{
    if (self.companyBlock) {
        self.companyBlock(self);
    }
}

@end






